package reflact.demo2_类对象的使用;

import java.lang.reflect.Constructor;

public class 构造 {
    public static void main(String[] args)throws Exception {
        Class c=Stu.class;
        //调用无参构造
        Stu s=(Stu)c.newInstance();
        System.out.println(s.getAge());
        Constructor con=c.getConstructor(int.class,String.class,int.class);
        s=(Stu)con.newInstance(30,"a1",40);
        System.out.println(s.getName());
    }

}
